var virtual_resource_data = [
    {value:113, name:'工业建筑工程'},
    {value:80, name:'房屋建筑工程'},
    {value:20, name:'其他工程'},
];
function getSum(data) {
    var sum = 0;
    data.forEach(function(item, idx) {
        sum += item.value;
    });
    return sum;
}
var virtual_resource_sum = getSum(virtual_resource_data);
var unit = "个";
var virtual_resource_option = {
    title: [{
        text: '工程总数量',
        left: '53%',
        top: '57%',
        textAlign: 'right',
        textBaseline: 'middle',
        textStyle: {
            color: '#fff',
            fontWeight: 'normal',
            fontSize: 12
        }
    }
    ],
    series: [
        {
            name: virtual_resource_sum + unit,
            type:'pie',
            silent: true,
            center: ['46%', '54%'],
            radius: ['36%', '66%'],
            itemStyle: {
                normal: {
                    color: '#fff',
                    borderColor: 'rgba(53,80,102,0.6)',
                }
            },
            label: {
                normal: {
                    show: true,
                    position: 'center',
                    formatter: '{a}\n',
                    color: '#fff',
                    fontSize: 16
                }
            },
            data: [1],
        },
        {
            name:'虚拟资源动态',
            type:'pie',
            center: ['46%', '54%'],
            radius: ['40%', '60%'],
            silent: true,
            itemStyle: {
                normal: {
                    color: "#00f2f4",
                    borderColor: '#132a40',
                    borderWidth: 1
                }
            },
            label: {
                normal: {
                    formatter: function(params){
                        var text = params.name + "：" + params.value + unit;
                        return text;
                    },
                    color: '#fff',
                    fontSize: 12,
                },          
            },
            labelLine: {
                normal: {
                    smooth: true,
                    length: 10,
                    length2: 25,
                    lineStyle: {
                        color: '#fff'
                    }
                }
            },
            data: virtual_resource_data
        }
    ]
};
var virtual_resource = echarts.init(document.getElementById('virtual-resource'));
virtual_resource.setOption(virtual_resource_option);